<template>
  <div class="cumi">
    <div class="cumi_top">
      <div class="from">
        <div class="fr">
          <yd-flexbox class="dl">
            <yd-flexbox-item>注册</yd-flexbox-item>
          </yd-flexbox>
          <yd-cell-group class="sumib">
            <yd-cell-item class="fr_item">
              <img slot="icon" src="../../static/login/2.png" />
              <yd-input
                slot="right"
                placeholder="请输入账号"
                required
                v-model="form.account"
              ></yd-input>
            </yd-cell-item>
            <yd-cell-item class="fr_item">
              <img slot="icon" src="../../static/login/3.png" />
              <yd-input
                slot="right"
                required
                v-model="form.password"
                type="password"
                placeholder="请输入密码"
              ></yd-input>
            </yd-cell-item>

            <div class="sf">
              <div class="loginsf">
                <!-- <img src="../../static/login/wxlogin.png" alt="" /> -->
                <span @click="$router.push('/login')">前往登录</span>
              </div>
            </div>
          </yd-cell-group>
        </div>
      </div>
      <yd-button-group style="top: 5.1rem;padding: 0 1.2rem;z-index:999">
        <yd-button
          size="large"
          type="primary"
          shape="circle"
          @click.native="register"
          >注册</yd-button
        >
      </yd-button-group>
    </div>
  </div>
</template>
<script>
import { register } from '@/api';
export default {
  name: 'logins',
  data() {
    return {
      form: {
        account: '',
        password: ''
      },
      show_clear: false,
      isshow: true
    };
  },
  created() {},
  methods: {
    register() {
      const { account, password } = this.form;
      const hasError = (() => {
        switch (true) {
          case !account:
            return '请输入账号';
          case !password:
            return '请输入密码';

          default:
            return false;
        }
      })();
      if (hasError === false) {
        register(this.form).then(res => {
          if (res.success) {
            this.$dialog.toast({
              mes: '注册成功',
              type: 'success',
              timeout: 800
            });
            this.$router.push('/login');
          } else {
            this.$dialog.toast({
              mes: res.msg,
              type: 'error',
              timeout: 800
            });
          }
        });
      } else {
        this.$dialog.toast({
          mes: hasError,
          type: 'error',
          timeout: 800
        });
      }
    }
  }
};
</script>
<style scoped lang="less">
.dl {
  padding: 0.5rem 0rem 0rem 0.5rem;
  font-size: 0.4rem;
  font-weight: bold;
  color: #4e4b4b;
  text-align: left;
}
.cumi {
  display: flex;
  height: 100%;
  flex-direction: column;
}
.cumi_top {
  height: 4rem;
  background: url(../../static/login/head.png);
  background-size: 100% 100%;
}
.cumi_button {
  height: 70%;
  background: #ffffff;
}
.from {
  position: absolute;
  top: 1.5rem;
  left: 0rem;
  height: 4.75rem;
  width: 100%;
  padding: 0.45rem;
}
.fr {
  background: #fff;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  box-shadow: 0px 10px 15px rgba(187, 238, 242);
  -moz-box-shadow: 0px 10px 15px rgba(187, 238, 242);
  -webkit-box-shadow: 0px 10px 15px rgba(187, 238, 242);
}
.fr_item {
  height: 0.7rem;
  margin: 0.4rem 0.5rem;
}
.sumib {
  border-radius: 5px;
}
.yd-cell-icon img {
  height: 0.4rem;
  padding-right: 0.1rem;
}
/deep/.yd-cell {
  border-radius: 5px;

  &:after {
    display: none !important;
  }
}
.yd-cell-right {
  min-height: 0.7rem;
}
.yd-cell-item {
  align-items: center;
  font-weight: bolder;
}
.yd-cell:after {
  height: 0px !important;
}
.yd-cell::after {
  height: 0px !important;
}
.yd-button {
  position: relative;
}
.yd-btn-block {
  height: 0.8rem;
  margin-top: 0.45rem;
}
.yd-checkbox-text {
  font-size: 0.25rem;
}
.yd-checkbox-icon {
  margin-right: 0.1rem;
}
.jz {
  text-align: right;
  color: #3fbed4;
}
.yd-btn-primary:not(.yd-btn-loading) {
  background-image: linear-gradient(to right, #4cf7f7, #636bdf);
}

.input-style input {
  font-size: 0.32rem !important;
  letter-spacing: 1px;
  font-weight: 500;
  width: 4rem;
}
.sf {
  display: flex;
  padding: 0rem 0.7rem;
  color: #999;
  align-items: center;
  justify-content: space-between;
}
.loginsf {
  font-size: 0.28rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  top: 1rem;
  left: calc(50% - 0.6rem);
}
.loginsf img {
  height: 0.5rem;
  padding-right: 0.15rem;
}
</style>
